package collection.homework;


import java.util.Comparator;

public class MyComparator implements Comparator {
    @Override
    public int compare(Object o1, Object o2) {
        collection.homework.Person p1 = (collection.homework.Person) o1;
        collection.homework.Person p2 = (collection.homework.Person) o2;
        if (p1.getScore() == p2.getScore()) {
            return p1.getAge() - p2.getAge();
        }
        return (int) (p2.getScore() - p1.getScore());
    }
}
